package com.eastedu.repository.ulearning.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.eastedu.repository.ulearning.po.TmpFilePO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * The interface Learning file mapper.
 *
 * @author 袁松明
 */
@Mapper
@DS("learning")
public interface LearningFileMapper extends BaseMapper<TmpFilePO> {

    /**
     * Update file by path.
     *
     * @param originalFileId the original file id
     * @param newPath        the new path
     * @param md5            the md 5
     * @param path           the path
     */
    @Update("UPDATE t_file_bak_20241202 SET path = #{newPath}, md5 = #{md5}, original_file_id = #{originalFileId} WHERE path = #{path}")
    void updateFileByPath(@Param("originalFileId") String originalFileId, @Param("newPath") String newPath, @Param("md5") String md5, @Param("path") String path);

    /**
     * Update vod lesson by path.
     *
     * @param originalFileId the original file id
     * @param newPath        the new path
     * @param path           the path
     */
    @Update("UPDATE t_vod_lesson_bak_20241202 SET courseware = #{newPath}, original_file_id = #{originalFileId} WHERE courseware = #{path}")
    void updateVodLessonByPath(@Param("originalFileId") String originalFileId, @Param("newPath") String newPath, @Param("path") String path);

    /**
     * Update by bak.
     */
    @Update("UPDATE t_vod_lesson t1 INNER JOIN t_vod_lesson_bak_20241202 t2 ON t1.lesson_id = t2.lesson_id SET t1.courseware = t2.courseware")
    void updateByBak();
}
